package cn.torna.tornaexample.controller.product;

import cn.torna.tornaexample.controller.product.vo.ProductVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 演示方法没有path
 * @author thc
 */
@RestController
@RequestMapping("shop/product")
@Tag(name = "商城产品")
public class RequestMappingValueController {

    @Operation(summary = "修改产品")
    @PutMapping
    public ProductVO put(@RequestBody ProductVO productVO) {
        return productVO;
    }

    @Operation(summary = "新增产品")
    @RequestMapping(method = RequestMethod.POST)
    public ProductVO post(@RequestBody ProductVO productVO) {
        return productVO;
    }

    @Operation(summary = "查询产品")
    @GetMapping
    public ProductVO get(
            @Schema(description = "产品id", example = "123")
            @PathVariable Integer productNo) {
        ProductVO productVO = new ProductVO();
        productVO.setProductNo(String.valueOf(productNo));
        return productVO;
    }

}
